<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
Object obj=request.getSession().getAttribute("role_resource");
if(null==obj){
	response.setStatus(1000);
	return;
}
%> 
	<script type="text/javascript">
	limit = 1000;
	
	//模板列表数据源
	var temp_store = new Ext.data.JsonStore({
		root : "data",
		totalProperty : "total",
		fields : ["cardid", "cardname", "type"],
		url : "work!queryTemp.action"
	});
	
	//模板错误状态数据源	
	var temstate_store = new Ext.data.JsonStore( {
		idProperty: "id",
		fields : ["id","text"],
		data:[{id:"0",text:"缺失模板"},{id:"1",text:"缺失电子模板"},{id:"2",text:"缺失纸质模板"}]
	});
	
	//模板列表数据源
	var rule_store = new Ext.data.JsonStore({
		root : "data",
		totalProperty : "total",
		fields : ["prodname", "tempid", "tempname","areaid","areaname"],
		url : "work!queryRule.action"
	});
	
	//规则错误状态数据源	
	var rulestate_store = new Ext.data.JsonStore( {
		idProperty: "id",
		fields : ["id","text"],
		data:[{id:"0",text:"无默认规则"},{id:"1",text:"默认规则未设置素材"},{id:"2",text:"默认规则素材无效"}]
	});
	
	//V+,AllReady数据源
	var check_store = new Ext.data.JsonStore({
		root : "data",
		totalProperty : "total",
		fields : ["type", "period", "state"],
		url : "work!queryVJACheck.action"
	});
	
	//V+,AllReady状态数据源	
	var checkstate_store = new Ext.data.JsonStore( {
		idProperty: "id",
		fields : ["id","text"],
		data:[{id:"0",text:"未验证"},{id:"1",text:"验证成功"},{id:"2",text:"验证失败"}]
	});
	
	//积分数据源
	var checkJF_store = new Ext.data.JsonStore({
		root : "data",
		totalProperty : "total",
		fields : ["pointtype","businessid", "billdate","ablepoint","lastbalpoint", "addpoint","expoint","adpoints","endpoints"],
		url : "work!queryJFCheck.action"
	});
	
	//积分类型，1:积分类 2:返现类 3:无积分及返现 4:积分+返现类"
	var checkJFstate_store = new Ext.data.JsonStore( {
		idProperty: "id",
		fields : ["id","text"],
		data:[{id:"1",text:"积分类"},{id:"2",text:"返现类"},{id:"3",text:"无积分及返现"},{id:"4",text:"积分+返现类"}]
	});
	
	//城市数据源
	var city_store = new Ext.data.JsonStore({
		root : "data",
		totalProperty : "total",
		fields : ["acctnbr", "stmtdate"],
		url : "work!queryCity.action"
	});
	
	var yyz_store = new Ext.data.JsonStore({
		root : "data",
		totalProperty : "total",
		fields : ["type", "period"],
		url : "work!queryYYZ.action"
	});
	
//————————————————————模板——————————————————————————————————————————————————————————	
	var tmplate = {
		xtype: "grid",
		border: false,
		autoExpandColumn: "stat",
		autoExpandMin: 200,
		store: temp_store,
		headersDisabled: true,
		columns: [
			new Ext.grid.RowNumberer( {header: "序号",width: 30}), 
			{dataIndex: "cardid",header: "卡产品编号", menuDisabled: true},
			{dataIndex: "cardname",header: "卡产品名称", menuDisabled: true},
			{dataIndex: "type",header: "状态",id: "stat", menuDisabled: true,
				renderer:function(input){	
					if(input=="") return input;
					var res = temstate_store.getById(input);
					return res.data.text;
	          	}
          	}
		]
	};
	
	
//————————————————————规则——————————————————————————————————————————————————————————		
	
	var rule = {
		xtype: "grid",
		border: false,
		autoExpandColumn: "state1",
		autoExpandMin: 200,
		store: rule_store,
		headersDisabled: true,
		columns: [
			new Ext.grid.RowNumberer( {header: "序号",width: 30}), 
			{dataIndex: "prodname",header: "卡产品名称", menuDisabled: true},
			{dataIndex: "tempname",header: "模板名称", menuDisabled: true},
			{dataIndex: "areaname",header: "区域名称", menuDisabled: true},
			{dataIndex: "state",header: "状态",id: "state1", menuDisabled: true,
				renderer: function(){
					return "未设置默认区域规则";
				}
          	}
		]
		/*,
		buttonAlign: "center",
		buttons: [
			{text: "验证",
   	        pressed: true,//显示按钮边框
           	handler: function(){
        	   var period = Ext.getCmp("c").getValue();
        	   if(period==""){
        		   Ext.Msg.show({
					   title:"提示",
					   msg:"请选择账期!",
					   buttons:Ext.Msg.OK,
					   icon: Ext.MessageBox.INFO
					}); 
        		   return;
        	   }
        	   	rule_store.baseParams["period"] = period;
        	   	rule_store.load({params:{start:0,limit:limit}});
	           }	    		
	    	}
		]*/
	};
	
//————————————————————V+—————————————————————————————————————————————————		

	var check_VV = {
		xtype: "grid",
		border: false,
		autoExpandColumn: "state",
		autoExpandMin: 200,
		store: check_store,
		headersDisabled: true,
		columns: [
			new Ext.grid.RowNumberer( {header: "序号",width: 30}), 
			{dataIndex: "type",header: "检查类型", menuDisabled: true},
			{dataIndex: "period",header: "账期", menuDisabled: true},
			{dataIndex: "state",header: "状态",id:"state", menuDisabled: true,
				renderer:function(input){
					if(""==input)return input;
	         		var res2=checkstate_store.getById(input);
				  	return res2.data.text;
	          	}
          	}
		]/*,
		buttonAlign: "center",
		buttons: [
			{text: "验证",
   	        pressed: true,//显示按钮边框
           	handler: function(){
        	   var period = Ext.getCmp("c").getValue();
        	   if(period==""){
        		   Ext.Msg.show({
					   title:"提示",
					   msg:"请选择账期!",
					   buttons:Ext.Msg.OK,
					   icon: Ext.MessageBox.INFO
					}); 
        		   return;
        	   }
        	   	check_store.baseParams["checkVJAData.period"] = period;
				check_store.load({params:{start:0,limit:limit}});
	           }	    		
	    	}
		]*/
	};
	
//————————————————————积分—————————————————————————————————————————————————		

	var check_JJ = {
		xtype: "grid",
		border: false,
		autoExpandColumn: "ablepoint",
		autoExpandMin: 200,
		store: checkJF_store,
		headersDisabled: true,
		columns: [
			new Ext.grid.RowNumberer( {header: "序号",width: 30}), 
			{dataIndex: "pointtype",header: "积分类型", menuDisabled: true,
				renderer:function(input){
					if(""==input)return input;
	         		var res2=checkJFstate_store.getById(input);
				  	return res2.data.text;
	          	}	
			},
			{dataIndex: "businessid",header: "账号",id:"ablepoint", menuDisabled: true},
			{dataIndex: "ablepoint",header: "本期积分余额", menuDisabled: true},
			{dataIndex: "lastbalpoint",header: "上期积分余额", menuDisabled: true},
			{dataIndex: "addpoint",header: "本期新增积分", menuDisabled: true},
			{dataIndex: "expoint",header: "本期兑换积分", menuDisabled: true},
			{dataIndex: "adpoints",header: "本期调整积分", menuDisabled: true},
			{dataIndex: "endpoints",header: "本期失效积分", menuDisabled: true}
		],
		/*buttonAlign: "center",
		buttons: [
			{text: "验证",
   	        pressed: true,//显示按钮边框
           	handler: function(){
        	   var period = Ext.getCmp("c").getValue();
        	   if(period==""){
        		   Ext.Msg.show({
					   title:"提示",
					   msg:"请选择账期!",
					   buttons:Ext.Msg.OK,
					   icon: Ext.MessageBox.INFO
					}); 
        		   return;
        	   }
        	   checkJF_store.baseParams["period"] = period;
        	   checkJF_store.load({params:{start:0,limit:limit}});
	           }	    		
	    	}
		],*/
		bbar : new Ext.ux.PagingToolbar( {
			pageSize : limit,
			store:checkJF_store
		})
	};
	
//————————————————————城市———————————————————————————————————————————————————————————	
	
	var city = {
			xtype: "grid",
			border: false,
			autoExpandColumn: "state",
			autoExpandMin: 200,
			store: city_store,
			headersDisabled: true,
			columns: [
				new Ext.grid.RowNumberer( {header: "序号",width: 30}), 
				{dataIndex: "acctnbr",header: "账号", menuDisabled: true},
				{dataIndex: "stmtdate",header: "账期",id: "state", menuDisabled: true},
				{header:"状态",renderer:function(){return "未设置城市";}}
			],
			buttonAlign: "center",
			buttons: [
				/*{text: "验证",
		       	pressed: true,//显示按钮边框
			   	handler: function(){
				   var period = Ext.getCmp("c").getValue();
				   if(period==""){
					   Ext.Msg.show({
						   title:"提示",
						   msg:"请选择账期!",
						   buttons:Ext.Msg.OK,
						   icon: Ext.MessageBox.INFO
						}); 
					   return;
				   }
				   city_store.baseParams["period"] = period;
				   city_store.load({params:{start:0,limit:limit}});
			       }	    		
				},*/{
				text: "设置默认城市",
				pressed: true,//显示按钮边框
				handler: function(){
					var period = Ext.getCmp("c").getValue();
				   if(period==""){
					   Ext.Msg.show({
						   title:"提示",
						   msg:"请选择账期!",
						   buttons:Ext.Msg.OK,
						   icon: Ext.MessageBox.INFO
						}); 
					   return;
				   }
					Ext.Ajax.request({
						clientValidation: true,
						params:{period:period},
						url:"work!updateCity.action",
						success: function(response){
							var d=eval("("+response.responseText+")");
							Ext.Msg.show({
							   title:"提示",
							   msg:"成功设置"+d.code+"条数据!",
							   buttons:Ext.Msg.OK,
							   icon: Ext.MessageBox.INFO
							});
							city_store.baseParams["period"] = period;
							city_store.load({params:{start:0,limit:limit}});							        		
						}
					});
				}}
			]
		};

//————————————————————预印纸——————————————————————————————————————————————————————————		
	var yyz = {
		xtype: "grid",
		border: false,
		autoExpandColumn: "stat",
		autoExpandMin: 200,
		store: yyz_store,
		headersDisabled: true,
		columns: [
			new Ext.grid.RowNumberer( {header: "序号",width: 30}), 
			{dataIndex: "type",header: "卡产品名称", menuDisabled: true},
			{dataIndex: "period",header: "外包商", menuDisabled: true},
			{dataIndex: "state",header: "状态",id: "stat", menuDisabled: true,
				renderer:function(input){	
					return "缺失有效预印纸";
	          	}
          	}
		]
	};	
	
//———————————————————————————————————————————————————————————————————————————————————		
	var selbutn = new Ext.Panel({
		id:"selbutn",
		border: false, 
		layout: "card",
		activeItem: 0,
	    tbar: ["-",{
			xtype: "tbtext",
			text: "账期:"
		},{
			id: "c",
			xtype:"datefield",
			format:"Y-m-d",
			editable :false,
			listeners:{
				"render":function(){
					Ext.Ajax.request({
						clientValidation: true,
						url:"work!getPeriod.action",
						success: function(response){
							var d=eval("("+response.responseText+")");   
							if(d.data){
								var period = d.data;
								period = period.substr(0,4)+"-"+period.substr(4,2)+"-"+period.substr(6,2);
								Ext.getCmp("c").setValue(period);
							}
						}
					});
				},
				"select":function(){					
					if(rule_store){
						rule_store.removeAll();
					}
					if(city_store){
						city_store.removeAll();
					}
					if(check_store){
						check_store.removeAll();
					}
					if(check_store){
						check_store.removeAll();
					}
					if(checkJF_store){
						checkJF_store.removeAll();
					}
					if(yyz_store){
						yyz_store.removeAll();
					}
				}
			}
		},"-",{
	           text: "模板",
	           pressed: true,//显示按钮边框
	           tooltip :"与账期无关!",
	           width:"80",
	           handler: function(){
	        		temp_store.load({params:{start:0,limit:limit}});
	           		Ext.getCmp("selbutn").layout.setActiveItem(0);
	           }
	        },"-",{
	           text: "规则",
	           tooltip :"请先选择账期!",
	           width:"80",
	           pressed: true,//显示按钮边框
	           handler: function(){	        	   
	        	   	var period = Ext.getCmp("c").getValue();
	        		if(period!=""){
	        			rule_store.baseParams["period"] = period;
	        			rule_store.load({params:{start:0,limit:limit}});
	        		}
	           		Ext.getCmp("selbutn").layout.setActiveItem(1);
	           }
	        },"-",{
	           text: "城市",
	           tooltip :"请先选择账期!",
	           width:"80",
	           pressed: true,//显示按钮边框
	           handler: function(){
	        	   	var period = Ext.getCmp("c").getValue();
	        		if(period!=""){
	        			city_store.baseParams["period"] = period;
	 				   	city_store.load({params:{start:0,limit:limit}});
	        		}
	           		Ext.getCmp("selbutn").layout.setActiveItem(2);
	           }
	        },"-",{
		           text: "预印纸",
		           tooltip :"请先选择账期!",
		           width:"80",
		           pressed: true,//显示按钮边框
		           handler: function(){
		        	   	var period = Ext.getCmp("c").getValue();
		        		if(period!=""){
		        			yyz_store.baseParams["period"] = period;
		 				   	yyz_store.load({params:{start:0,limit:limit}});
		        		}
		           		Ext.getCmp("selbutn").layout.setActiveItem(5);
		           }
		      },"-",{
	           text: "V+",
	           tooltip :"请先选择账期!",
	           width:"80",
	           pressed: true,//显示按钮边框
	           handler: function(){	         		
					check_store.baseParams = {};
					check_store.baseParams["checkVJAData.type"] = "V+";						
					var period = Ext.getCmp("c").getValue();
	        		if(period!=""){
	        			check_store.baseParams["checkVJAData.period"] = period;	
	        			check_store.load({params:{start:0,limit:limit}});
	        		}
	           		Ext.getCmp("selbutn").layout.setActiveItem(3);
	           }
	        },"-",{
	           text: "积分",
	           tooltip :"请先选择账期!",
	           width:"80",
	           pressed: true,//显示按钮边框
	           handler: function(){   
	        		checkJF_store.baseParams = {};
	        		var period = Ext.getCmp("c").getValue();
	        		if(period!=""){
						checkJF_store.baseParams["period"] = period;
						checkJF_store.load({params:{start:0,limit:limit}});
	        		}
	           		Ext.getCmp("selbutn").layout.setActiveItem(4);
	           }      
	    	},"-","&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp",{
	    		text: "<font color='red'>全部通过</font>",
    	        pressed: true,//显示按钮边框
 	           tooltip :"请先选择账期!",
 	           width:"80",
	           	handler: function(){
	        	   var period = Ext.getCmp("c").getValue();
	        	   if(period==""){
	        		   Ext.Msg.show({
						   title:"提示",
						   msg:"请选择账期!",
						   buttons:Ext.Msg.OK,
						   icon: Ext.MessageBox.INFO
						}); 
	        		   return;
	        	   }
	        	   Ext.Ajax.request({
						clientValidation: true,
						params: {"checkVJAData.period": period},
						url:"work!updateCheck.action",
						success: function(response){
							var d=eval("("+response.responseText+")");
							Ext.Msg.show({
							   title:"提示",
							   msg:"操作成功!",
							   buttons:Ext.Msg.OK,
							   icon: Ext.MessageBox.INFO
							});       		
						}
					});
	           }	    		
	    	}
	    ],
	    items: [tmplate,rule,city,check_VV,check_JJ,yyz]
});
	
	
	
	var CenterPanel=Ext.getCmp("CenterPanel");
	CenterPanel.removeAll();
	CenterPanel.add(selbutn);
	CenterPanel.doLayout();
</script>